﻿<script language="javascript">
    $(document).ready(function(){
        $("#checkall").click(function(){
            var checked_status = this.checked;
            $('input[type="checkbox"]').each(function(){
               this.checked = checked_status;
            });
        });
    });
</script>
<?php echo $this->Form->create('SanPham',array('action'=>'admin_process')); ?>
<script language="javascript">
    $(document).ready(function(){
        $("#checkall").click(function(){
            var checked_status = this.checked;
            $('input[type="checkbox"]').each(function(){
                this.checked = checked_status;
            });
        });
    });
</script>
<div>
    <h1 align="center">Danh Sách Sản Phẩm</h1>
<table class="">
    <thead>
        <tr class="trhead">
			<th><?php echo $this->Form->checkbox('all',array('id'=>'checkall')); ?></th>
            <th scope="col" class="rounded-company">
                ID SẢN PHẨM
            </th>

            <th scope="col" class="rounded">TÊN SẢN PHẨM</th>
		<th scope="col" class="rounded">ẢNH SẢN PHẨM</th>
            <th scope="col" class="rounded">KHUYẾN MÃI</th>
            <th scope="col" class="rounded">GIÁ BÁN SỈ (VND)</th>
            <th scope="col" class="rounded">GIÁ BÁN LẺ (VND)</th>
            <th scope="col" class="rounded">NGÀY NHẬP</th>
            <th scope="col" class="rounded">CẬP NHẬT</th>
            <th scope="col" class="rounded-q4">THAY ĐỔI</th>
        </tr>
    </thead>
    <?php foreach($sanphams as $sanpham) : ?>
    <tr>
		<td><?php echo $this->Form->checkbox('SanPham.id.'.$sanpham['SanPham']['id']); ?></td>
        <td><?php echo $sanpham['SanPham']['id']; ?></td>

        <td>
            <?php echo $sanpham['SanPham']['TENSP']; ?>
        </td>
	<td><?php
            if($sanpham['SanPham']['hinhanh']) {
                $thumbnail = $sanpham['SanPham']['hinhanh'];
            } else $thumbnail = 'NO IMAGE';
            echo $this->Html->image($thumbnail,array('border' => 0, 'height' => '50px', 'width' => '50px', 'alter' => 'NO IMAAGE','rel'=>"lightbox"), array('escape' => false));
            ?>
            <?php //echo $sanpham['SanPham']['hinhanh']; ?>
        </td>
        <td>
            <?php echo $sanpham['SanPham']['SOLUONGKHUYENMAI'] ; ?>
        </td>

        <td>
            <?php echo $sanpham['SanPham']['GIABANSI']; ?>
        </td>
        <td>
            <?php echo $sanpham['SanPham']['GIABANLE']; ?>
        </td>
        <td>
            <?php echo date('d-m-Y', strtotime($sanpham['SanPham']['created'])); //$this->Time->niceShort($sanpham['SanPham']['created']) ?>
        </td>
        <td>
            <?php echo date('d-m-Y', strtotime($sanpham['SanPham']['modified']));  ?>
        </td>
        <td>
            <?php
            if ($this->Session->read('quyen') != 'nhanvien') {
                echo $this->Html->link($this->Html->image('/images/user_edit.png'), array('action' => 'edit', $sanpham['SanPham']['id']), array('escape' => false));
            } else echo '&nbsp';
            //$this->Html->image('../images/user_edit.png')?>
            <?php if ($this->Session->read('quyen') == 'quantri') {
            echo $this->Html->link($this->Html->image('/images/trash.png'), array('action' => 'delete', $sanpham['SanPham']['id']),
                array('confirm' => 'Bạn có chắc muốn xóa?', 'escape' => false));
        }
            ?>
        </td>

    </tr>

   <?php endforeach; ?>
    <tr><?php /*echo $this->Form->create('SanPham');
        echo $this->Form->submit('Delete', array('controller' => 'sanphams','action' => 'deleteall'));
        echo $this->Form->end();*/
        ?>
    </tr>
</table>
<?php
     echo $this->Form->end('Xóa các mục đã chọn', array('action' => 'Delete'));
?>
</div>


<div id="pagination">
    <div class="paging">
        <?php echo $this->Paginator->first('Trang đầu'); ?>
        <?php echo $this->Paginator->prev('<<' . __('Lùi', true),
        array(), null, array('class' => 'disabled')); ?>
        <?php echo $this->Paginator->numbers(); ?>
        <?php echo $this->Paginator->next(__('Tới', true) . '>>',
        array(), null, array('class' => 'disabled')); ?>
        <?php echo $this->Paginator->last('Trang cuối'); ?>
    </div>
</div>
    <?php echo $this->Html->link('Thêm sản phẩm', array('controller' => 'sanphams', 'action' => 'add'), array('class' => 'add')); ?>
<div class="clear"></div>
